<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="num1">
    <input type="button" id="btn" value="输入">
    <div id="nums"></div>
    <script>
    // 有一个从小到大排好序的数组。现输入一个数，要求按原来的规律将它插入数组中。
        onload=function(){
            var arr=[1,2,3,4,5,6,7];
            nums.innerHTML=arr;
            btn.onclick=function() {
                arr.push(num1.value*1)
                arr.sort(function(a,b){
                  return  a-b;
                })
                num1.value='';
                nums.innerHTML=arr;
            }
        }
    </script>
</body>
</html>